package com.ffapp.demo.bean;


import com.amap.api.maps.AMap;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.VisibleRegion;

import java.io.Serializable;
import java.util.ArrayList;

public class MapDataListBean implements Serializable {
    private static final long serialVersionUID = 1L;

    private ArrayList<MapDataListData> list = new ArrayList<MapDataListData>();

    public ArrayList<MapDataListData> getList() {
        return list;
    }

    public void setList(ArrayList<MapDataListData> list) {
        this.list = list;
    }


    public MapDataListBean getFilterList(CameraPosition cameraPosition,AMap aMap){
        if(cameraPosition == null)return this;
        VisibleRegion region = aMap.getProjection().getVisibleRegion();
        LatLngBounds latLngBounds = aMap.getProjection().getVisibleRegion().latLngBounds;
//        Point point = new Point(0,0);
//       LatLng latLngTopleft =  aMap.getProjection().fromScreenLocation(point);
//        float distance_max = AMapUtils.calculateLineDistance(latLngTopleft,cameraPosition.target);
        ArrayList<MapDataListData> listR = new ArrayList<>();
//        float distance;
        for(MapDataListData data:list){
            if(latLngBounds.contains(data.getLatlng())){
                listR.add(data);
            }
        }
        MapDataListBean mapDataListBean = new MapDataListBean();
        mapDataListBean.setList(listR);
        return  mapDataListBean;
    }

}
